Repository navigation
id(world_net): make inbound_refusal_backpressures test deterministic (#5195) - #5215
Merged
Merged
Conversation
…5195) The shed leg raced the token-bucket refill: at 1_000 tokens/sec with a burst of 1, the drained bucket refills its single token in 1 ms, so any >= 1 ms scheduling stall between the two pre-auth charges admitted the second charge and failed "a pre-auth refusal sheds the stream" under load. Drop the test rates to 1 token/sec (burst still 1): the shed window becomes ~1 s, three orders of magnitude above scheduler jitter, while the authorized leg still completes in ~1 s inside its 3 s bound. Also bound the two previously bare first-charge awaits at 5 s so every await in the test fails loudly instead of stalling the suite. Test-only change; evaluator behavior untouched.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5195.
Root cause (the flake)
The test set
BucketLimits { frames_per_sec: 1_000, frame_burst: 1, bytes_per_sec: 1_000, byte_burst: 1 }. In the evaluator's milli-token buckets (src/abuse.rs), that is a 1_000 milli-token capacity refilling at 1_000 milli-tokens per millisecond: after the first pre-auth charge drains the bucket, a full token is back after 1 ms of wall time. The shed assertion — second pre-auth charge must be refused — therefore only holds if the test thread runs the second charge within the same ~1 ms. Any scheduling stall ≥ 1 ms between the two charges (parallel full-suite load, sandbox CPU throttling) admits the second charge,charge_inbound_framereturnstrue, and the test panics with "a pre-auth refusal sheds the stream". A timing assumption in the test, not a backpressure race: the lib path (refill, refusal, retry clamp) behaves exactly as designed at every step.The fix (test-only,
pkgs/id/src/world_net.rs)RETRY_FLOOR_MS) and then charges against the refilled bucket — ~1 s total, inside the existing 3 s bound.tokio::time::timeouts with loudexpects, so every await in the test is bounded: a wedged charge fails loudly in seconds instead of stalling a suite (relevant in the nix check phase, where the laptop setsmax-silent-time = 0).charge_inbound_frameare untouched, and the assertions still verify the same behavior — pre-auth refusal sheds immediately, authorized refusal waits out the refill and admits.Hang verdict (switch incident)
Not this test, on the evidence. Pre-fix, the unmodified test ran 450 times on the laptop with zero failures and zero hangs (240 isolated across 6 parallel streams, 60 pinned to one CPU with two busy hogs, 150 under 32-way CPU saturation). Code audit agrees: every wait in the test's path is a tokio sleep of a refusal delay clamped to [1 s, 60 s] by
Refusal::new, the two substantive second charges are already wrapped in 500 ms / 3 s timeouts, and the only unbounded awaits were the first charges against a fresh, full bucket (now bounded by this PR as well). A binary sitting single-threaded at 0 CPU for 52 minutes is far more consistent with an unbounded network await elsewhere in a check-phase suite (the id lib binary also carries live-iroh tests whose connects/receives have no outer timeout) than with this bounded test. The 52-minute hang remains unattributed — it is not evidence against this test, and this PR does not claim to fix it.Verification
world_net::tests22/22,abuse::tests12/12,frames::tests5/5.Observed while reproducing (separate, not fixed here)
Full-lib host runs currently abort in
cli::tests::module_trust_keys_are_repeatable_and_require_world_mode— unbounded stack recursion (overflows even withRUST_TEST_THREAD_STACK_SIZE=67108864), reproduced on several pre-existing primary-built lib binaries. It passes in the nix sandbox per the #5195 record, so it reads as a host-environment trigger. Filed as #5216.